import { AxiosResponse } from 'axios';
import { Candidate } from '../../types/Candidate';
import { JobDetail } from '../../types/Job';
import { axiosInstance } from '../../utils/Axios';
import { CandidateListApiResult, JobListApiResult } from '../model/JobModel';

// 创建职位详情
export const createJob = (
  formData: JobDetail
): Promise<AxiosResponse<JobDetail>> => {
  return axiosInstance.post('/job', { ...formData });
};

// 获取职位列表
export const getJobListData = (
  page: number
): Promise<AxiosResponse<JobListApiResult>> => {
  return axiosInstance.get('/joblist', {
    params: {
      page,
    },
  });
};

// 修改职位状态
export const updateJobStatus = (
  id: string,
  status: string
): Promise<AxiosResponse<null>> => {
  return axiosInstance.put('/job', {
    id,
    status,
  });
};

// 获取面试者
export const getCandidate = (
  id: string
): Promise<AxiosResponse<CandidateListApiResult>> => {
  return axiosInstance.get('/candidatelist', { params: { id } });
};

// 更新面试信息
export const updateCandidate = (
  data: Candidate
): Promise<AxiosResponse<null>> => {
  return axiosInstance.put('/candidate', { ...data });
};
